package Adapter.impl;

import Adapter.service.SpecUserService;
import Adapter.service.UserService;
import com.google.gson.Gson;

import java.util.List;
import java.util.Map;

/**
 * @author huace
 *
 * 对象适配器方式：实现目标接口
 */
public class SpecUserServiceAdapter implements SpecUserService {

    UserService userService;

    public SpecUserServiceAdapter(UserService userService) {
        this.userService = userService;
    }

    @Override
    public String findByJId() {
        Map<String, String> user = userService.findById();
        return new Gson().toJson(user);
    }

    @Override
    public String findJUser() {
        List<Map<String, String>> userList = userService.findUserList();
        return new Gson().toJson(userList);
    }
}
